<template>
  <div>
    <studentMainleft></studentMainleft>
  </div>
</template>

<script>
import studentMainleft from "@/components/studentMainleft";
export default {
  components: {
    studentMainleft
  },

  data() {
    return {};
  },
  created() {
    this.IfChangePwd();
  },
  mounted() {},
  methods: {
    IfChangePwd() {
      var session = sessionStorage.getItem("user");
      var user = JSON.parse(session);
      var WorkerCarid = user.WorkerCarid.substring(12, 18);
      var pwd = sessionStorage.getItem("pwd");
      if (WorkerCarid == pwd) {
        console.log("请修改密码");
        this.$prompt("为了您的账号安全请先修改密码", "请修改密码", {
          confirmButtonText: "确定"
        }).then(({ value }) => {
          this.$axios({
            method: "put",
            url: this.$api.UpdatePasswprd,
            params: {
              oldPwd: pwd,
              newPwd: value,
              userName: user.StuId
            }
          }).then(res => {
            console.log(res);
            if (res.data.code == 200) {
              this.$message({
                message: "修改密码成功",
                type: "success"
              });
            }
          });
        });
      }
      sessionStorage.removeItem("pwd");
    }
  }
};
</script>

<style scoped>
</style>
